<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>文章列表--layui后台管理模板 2.0</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="../../layui/css/layui.css" media="all" />
	<link rel="stylesheet" href="../../css/public.css" media="all" />
</head>
<body class="childrenBody">
<form class="layui-form" style="width:80%;">
	<div class="layui-form-item">
		<label class="layui-form-label">手机号</label>
		<div class="layui-input-inline">
			<input type="text" class="layui-input register_phone" id="register_phone" lay-verify="register_phone" placeholder="请输入手机号">
		</div>
		<div class="layui-form-mid layui-word-aux">
			<input type="button" class="layui-btn layui-btn-xs" name="getCode" id="getCode" value="获取验证码" />
		</div>
	</div>
	<!--<div class="layui-form-item">
		<label class="layui-form-label">输入邮箱</label>
		<div class="layui-input-inline">
			<input type="text" id="email" name="email" placeholder="请输入邮箱作为登录用户名" autocomplete="off" class="layui-input email">
		</div>
		<div class="layui-form-mid layui-word-aux">
			<a class="layui-btn layui-btn-xs" id="getCode" lay-filter="getCode">获取验证码</a>
		</div>	
	</div>-->
	<div class="layui-form-item" id="register_checkCode" style="display: none;">
		<label class="layui-form-label">验证码</label>
		<div class="layui-input-inline">
			<input type="text" class="layui-input register_checkCode" lay-verify="register_checkCode" placeholder="请输入验证码">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">输入密码</label>
		<div class="layui-input-inline">
			<input type="text" name="register_password" class="layui-input register_password" lay-verify="register_password" placeholder="请输入登录密码">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">确认密码</label>
		<div class="layui-input-inline">
			<input type="text" class="layui-input check_register_password" lay-verify="check_register_password" placeholder="请确认密码">
		</div>
	</div>
	
	<div class="layui-form-item">
		<label class="layui-form-label">旺旺号</label>
		<div class="layui-input-inline">
			<input type="text" class="layui-input user_wangwang" lay-verify="user_wangwang" placeholder="请输入旺旺号">
		</div>
	</div>
	
	<div class="layui-form-item">
		<label class="layui-form-label">微信号</label>
		<div class="layui-input-inline">
			<input type="text" class="layui-input register_wx" lay-verify="register_wx" placeholder="请输入微信号">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">QQ号码</label>
		<div class="layui-input-inline">
			<input type="text" class="layui-input register_qq" lay-verify="register_qq" placeholder="请输入QQ号">
		</div>
	</div>
	
	<div class="layui-form-item userAddress">
			<label class="layui-form-label">收货地址</label>
			<div class="layui-input-inline">
				<select   name="province" lay-verify="required" lay-filter="province" class="province" >
					<option value="" >请选择省</option>
				</select>
			</div>
			<div class="layui-input-inline">
				<select  name="city" lay-verify="required" lay-filter="city" id="city" disabled>
					<option value="">请选择市</option>
				</select>
			</div>
			<div class="layui-input-inline">
				<select  name="area" lay-verify="required" lay-filter="area" id="area" disabled>
					<option value="">请选择县/区</option>
				</select>
			</div>
		</div>
	
	
	
	<div class="layui-form-item layui-row layui-col-xs12">
		<div class="layui-input-block">
			<button class="layui-btn layui-btn-sm" lay-submit="" lay-filter="register">立即添加</button>
			<button type="reset" class="layui-btn layui-btn-sm layui-btn-primary">取消</button>
		</div>
	</div>
</form>
<script type="text/javascript" src="../../layui/layui.js"></script>

	<!-- <script src="http://code.jquery.com/jquery-latest.js"></script> -->
<!--<script type="text/javascript" src="/static/js/userAdd.js"></script>-->
<script>
layui.config({
    base : "../../js/"
}).extend({
    "address" : "address"
})
	layui.use(['laypage', 'layer', 'form',"address"], function() {
	var form = layui.form,
		layer = layui.layer,
		layedit = layui.layedit,
		laydate = layui.laydate,
		address = layui.address,
		$ = layui.jquery;
address.provinces();
	$("#getCode").click(function() {
		console.log("ces ----------------");
		if ($("#register_phone").val() == "" || $("#register_phone").val() == null) {
			layer.msg("请先输入手机号");
		} else{
			var code = $("#getCode");
			$("#register_checkCode").show();
		   // code.attr("disabled","disabled");
		    var time = 60;
		    var set = setInterval(function(){
		    	if(time==0){
			    	code.attr("disabled",false);
			    	code.val("重新获取");
			    	time=6;
			    	clearInterval(set);
			    	return false;
			    }else{
			    	code.attr("disabled",true);
			    	code.val("("+time+")秒后重新获取");
			    	time--;
			    	
			    	//跳转获取验证码
			    	$.ajax({
			    		type:"post",
			    		url:"",
			    		async:true
			    	});
			    }
		    },1000)
		}
		    
		    
		    
			/*$.ajax({
				type: "post",
				url: '/index/Mail/getCode',
				data: 'email=' + $('#email').val(),
				dataType: 'JSON',
				success: function(data) {
					layer.msg(data.msg);
				}
			});
			$("#checkCode").show();*/
		
	})
	form.verify({
		register_phone: function(value) {
			if(!(/^1([38]\d|5[0-35-9]|7[3678])\d{8}$/.test(value))) {
				return '手机格式错误';
			}
		},
		register_password: [
			/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,12}$/, '密码必须为英文和数字的组合，长度在6-12位之间'
		],
		check_register_password: function(value) {
			var checkpassval = $('input[name=register_password]').val();
			if(value != checkpassval) {
				return '两次输入的密码不一致';
			}
		},
		register_qq:function(value){
			if(!/^[1-9][0-9]{4,}$/.test(value)){
				return "请输入正确的QQ号";
			}
		},
		/*nickname: function(value) {
			if(value == "") {
				return "请输入昵称";
			} else {
				for(var i = 0; i < data.check.length; i++) {
					if(value == data['check'][i]['nickname']) {
						return '昵称已被使用，请使用新的昵称';
					}
				}
			}

		},*/
		register_checkCode: function(value) {
			if(value == "") {
				return '请先获取验证码并输入';
			}
		},
		user_wangwang: function(value) {
			if(value == "") {
				return '请输入旺旺号';
			}
		},
		province: function(value) {
			if(value == "") {
				return '请选择省份';
			}
		},
		city: function(value) {
			if(value == "") {
				return '请选择市区';
			}
		},
		area: function(value) {
			if(value == "") {
				return '请选择地区';
			}
		}
	});
	//发送注册信息
	form.on('submit(register)', function(data){
	
				
				$.ajax({
					type:"post",
					url:'http://127.0.0.1:88/index.php/login/Register/font',///admin/Register/index
					data:'data='+JSON.stringify({
						'register_checkCode': $('.register_checkCode').val(),
						'register_phone': $('.register_phone').val(),
						'register_password': $('.register_password').val(),
						'register_wx': $('.register_wx').val(),
						'register_qq': $('.register_qq').val(),
						'user_wangwang': $('.user_wangwang').val(),
						'province': $('.province').val(),
						'city': data.field.city,
						'area': data.field.area,
					}),
					dataType:'JSON',
					success:function(obj){
						
						if (obj.code==200) {
							layer.msg(obj.msg)
							setTimeout(function(){
				            	window.parent.location.reload();
				        	},2000);
						} else{
							layer.msg(obj.msg)
						}
					}
				});
				/*layer.alert(JSON.stringify(data.field), {
				  title: '最终的提交信息'
				})*/
				return false;
			});
	 //监听提交		
			
			
});</script>
</body>
</html>